/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.shoppingsystem.view.converters;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.beansbinding.Converter;

/**
 *
 * @author Usuario
 */
public class DateString extends Converter<Object, Object> {

    public final static SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    
    @Override
    public Object convertForward(Object value) {
        return formatter.format((java.util.Date) value);
    }

    @Override
    public Object convertReverse(Object value) {
        try {
            return formatter.parse(String.valueOf(value));
        } catch (ParseException ex) {
            return new java.util.Date();
        }
    }

}
